'use strict';

/**
 * @param {Egg.Application} app - egg application
 */
module.exports = app => {
  const { router, controller } = app;
  // 一、router-controller
  // get的query参数
  router.get('/fruits', controller.fruits.getQuery);
  // get的params参数
  router.get('/fruits/:id', controller.fruits.getParams);
  // 页面
  router.get('/form', controller.fruits.formPage);
  // post
  router.post('/fruits', controller.fruits.postRequest)

  // 二、plugin-jwt
  router.post('/login', controller.loginJwt.login)
  router.get('/getMessage', controller.loginJwt.getMessage)

  // 三、中间件
  router.get('/getMessage1', app.middleware.checkToken(), controller.loginJwt.getMessage1)

  // 四、数据持久化（mysql）
  router.post('/student', controller.studnet.addStudent)
  router.delete('/student/:id', controller.studnet.deleteStudent)
  router.post('/student/:id', controller.studnet.updateStudent)
  router.get('/student', controller.studnet.getStudent)
  router.get('/student/:id', controller.studnet.getStudentById)
};
